-- drop function if exists sm_rdd.fv_get_lambda_param(text);
create or replace function sm_rdd.fv_get_lambda_param
(
  i_lambda_text   text
)
returns varchar(64)[]
as
$$
-- declare

begin

  return
    (
      select array_agg(v_param)
      from 
        (
          select (regexp_matches(',' || (regexp_matches(i_lambda_text, '(.*?)(?=\-\>)'))[1] || ',', '(?<=\s*,\s*)([a-zA-Z_][a-zA-Z0-9_]*\s+[a-zA-Z0-9_]+(\([\d,\s]+\))?(\[\d*\])?)(?=\s*,\s*)', 'g'))[1] v_param
        ) t_param
    ) 
  ;
end
$$
language plpgsql volatile
cost 100;

-- select sm_rdd.fv_get_lambda_param('x text[], y int -> (select sum(length(t)) from unnest(x) t limit y)')